package com.founder.chd_daily_query.controller;


import com.alibaba.fastjson.JSONObject;
import com.founder.chd_daily_query.service.RedisPresentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
    @RequestMapping(value = "/PresentQuery")
public class PresentController {

    @Autowired
    RedisPresentService redisPresentService;

    @GetMapping(value = "common/{key}/{num}")
    public List<JSONObject> presentCommon(@PathVariable(value = "key") String key, @PathVariable(value = "num") Integer num){
        List<JSONObject> metaInfo = redisPresentService.getMetaInfo(key, num);
        return metaInfo;

    }

    @GetMapping(value = "accurately/{model}/{field}/{value}/{num}")
    public List<JSONObject> presentCommon(@PathVariable(value = "model") String model,
                                          @PathVariable(value = "field") String field,
                                          @PathVariable(value = "value") String value,
                                          @PathVariable(value = "num") Integer num)
            throws NoSuchMethodException, ClassNotFoundException {
        List<JSONObject> metaInfo = redisPresentService.getMetaInfoAccurately(model,field, value, num);
        return metaInfo;

    }
}
